﻿<div class="top-row ps-3 navbar navbar-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="">图灵进销存管理</a>
        <button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <RadzenPanelMenu>
        <RadzenPanelMenuItem class="bi bi-list-nested-nav-menu" Text="主页" Path="/" Match="NavLinkMatch.All" Icon="account_circle"></RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="组织机构" Icon="payment">
            <RadzenPanelMenuItem Text="权限管理" Path="auth" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="角色管理" Path="role" Icon="input"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="员工管理" Path="employee" Icon="description"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="销售管理" Icon="payment">
            <RadzenPanelMenuItem Text="销售单" Path="saleorder" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="退货单" Path="saleorderreturn" Icon="input"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="采购管理" Icon="payment">
            <RadzenPanelMenuItem Text="采购单" Path="buyorder" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="退货单" Path="buyorderreturn" Icon="input"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="客商管理" Icon="payment">
            <RadzenPanelMenuItem Text="客户管理" Path="customer" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="供应商管理" Path="supplier" Icon="input"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="商品管理" Icon="payment">
            <RadzenPanelMenuItem Text="商品分类" Path="producttype" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="商品管理" Path="product" Icon="input"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="计量单位" Path="unit" Icon="description"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="库存管理" Icon="payment">
            <RadzenPanelMenuItem Text="产品库存" Path="productsearch" Icon="check_circle"></RadzenPanelMenuItem>
            <RadzenPanelMenuItem Text="产品盘点" Path="productchecksave" Icon="input"></RadzenPanelMenuItem>
        </RadzenPanelMenuItem>
        <RadzenPanelMenuItem Text="收支费用" Path="finance" Icon="input"></RadzenPanelMenuItem>
    </RadzenPanelMenu>
</div>

@code {
    [CascadingParameter]
    public MainLayout Parent { get; set; }

    public void AddLoginUser()
    {
        Parent.InsertLoginUser();

        //Parent.companyNames.Insert(0, AppSession.User.Name);
        //Parent.value = AppSession.User.Name;

    }

    private bool collapseNavMenu = true;

    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }

    protected override void OnInitialized()
    {
        base.OnInitialized();

        if(AppSession.User != null)
        {
            AddLoginUser();
        }
    }
}
